var para = {}
var items  = []
var pageNumber = 1
var pageSize = 10

function loadData (data, isup){
	items = items.concat( data.themeDetails.list )
	
	$("#thelist").setTemplateURL(para.page);
	$("#thelist").setParam("width", window.screen.width); 
	if(data.themeDetails.lastPage == true){
		$("#thelist").setParam("lastPage", true); 
	}
	$("#thelist").processTemplate(items);
}

//加载评论
function loadmore(){
	loadDownFn()
}

/*function test111(aaa){
	alert("asdsadsadas")
}*/

function loaded(top, obj) {
	pageNumber = 1
	//$("#wrapper").css('top', top)
	para = getParaObj(obj)
	loadUpFn(para)
}

function loadUpFn(para){
	pageNumber = 1
	items = []
	var p = getParaObj(para.para)
	p.page = pageNumber
	p.pageSize = pageSize
	
    ajax(para.url, p, function(data){
    	pageNumber++
		loadData(data, false)
	})
}

function loadDownFn(){ 
	var p = getParaObj(para.para)
	p.page = pageNumber
	p.pageSize = pageSize
    ajax(para.url, p, function(data){
    	pageNumber ++
		//如果是第一页
		if(data.lastPage){
			lastPage = data.lastPage
			$(".loadmore").css('display','none')
		}
		loadData(data, true)
	})
}
function getParaObj(oldObj) {
    var result = {}
    var sdic = Object.keys(oldObj).sort()
    for (var i = 0; i < sdic.length; i++) {
      result[sdic[i]] = oldObj[sdic[i]]
    }
    return result
}
/*****************************************H5与终端交互*****************************************/